package com.dcy.memento.theory;

import lombok.Getter;
import lombok.Setter;

/**
 * @Author：dcy
 * @Description:
 * @Date: 2021/1/29 15:28
 */
@Getter
@Setter
public class Originator {

    /**
     * 状态
     */
    private String state;

    /**
     * 保存状态对象 Memento
     */
    public Memento saveStateMemento() {
        return new Memento(state);
    }

    /**
     * 通过备忘录对象，恢复状态
     */
    public void getStateFromMemento(Memento memento) {
        state = memento.getState();
    }
}
